﻿

namespace Stee.CAP8.MessageBus.SampleUI
{
    using System;
    using System.Windows;
    using Stee.CAP8.MessageBus.SampleUI.ViewModels;

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            this.InitializeComponent();
        }


        private void SendMessageOnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                MessageViewModel vm = this.DataContext as MessageViewModel;
                vm?.PublishNewMessages();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error on re-sending new messages. Error: {ex.Message}");
            }
        }

        private void ClearMessageOnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                MessageViewModel vm = this.DataContext as MessageViewModel;
                vm?.ClearMessages();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error on re-sending new messages. Error: {ex.Message}");
            }
        }
    }
}
